package dynamicproxy.jdk;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;

/**
 * @author hht
 * @ClassName JdkProxyTest
 * @Description TODO
 * @Date 2019/5/28 16:17
 * @VERSION 1.0
 */
public class JdkProxyTest {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class proxyClass = Proxy.getProxyClass(JdkProxy.class.getClassLoader(),Person.class);
        final Constructor cons = proxyClass.getConstructor(InvocationHandler.class);
        final  InvocationHandler ih = new JdkProxy(new Girl());
        Person girl = (Person) cons.newInstance(ih);
        girl.findFrind();
    }
}
